<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateServiceFeeLogTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('service_fee_log', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('order_id', 50)->default('')->comment('关联订单ID');
            $table->string('fee_type', 10)->default('consume')->comment('抽成类型：consume-消费，withdraw-提现');
            $table->double('coin', 10, 1)->default(0.0)->comment('费用数');
            $table->double('rate', 3, 2)->default(0.00)->comment('抽成比例');
            $table->timestamps();
            $table->tinyInteger('flag')->default(1)->comment('1-有效，0-无效');
            $table->index('order_id', 'order_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('service_fee_log');
    }
}
